#include <iostream>
#include <cstring>
using namespace std;

int main(){
	int n;
	cin >> n;
	int table[10001];
	memset(table, 0, sizeof(table));
	table[0] = -1;
	int result = 0;
	int max1 = 0;
	int max2 = 0;
	for(int i = 1; i <= n; i++){
		int temp;
		cin >> temp;
		table[temp]++;
		if(table[temp] > table[max1]){
			if(temp == max2) max2 = max1;
			max1 = temp;
		}
		else if(table[temp] > table[max2] && temp != max1) max2 = temp;
		if(table[max1] >= 4 || (table[max1] >= 2 && table[max2] >= 2)){
			result++;
			max1 = 0;
			max2 = 0;
			memset(table, 0, sizeof(table));
			table[0] = -1;
		}
	}
	cout << result << endl;
}
